#!/bin/bash

outputDir=./output
envFile=./data/env.cfg

# 1.source env file && mkdir dir
source $envFile
mkdir -p ./output
mkdir -p ./output/conf
mkdir -p ./output/conf/dxc-server
mkdir -p ./output/conf/sed

# 2.copy docker-compose.yaml
cp ./template/docker-compose.yaml ./output

# 3.generate dxc-server conf
sed -e "s/ORG/$ORG/g" \
        -e "s/AZ/$AZ/g" \
        -e "s/SU/$SU/g" \
        -e "s/WKS/$WKS/g" \
        -e "s/ENV/$ENV/g" \
         ./template/conf/dxc-server/app.toml  > ./output/conf/dxc-server/app.toml

# 4.generate sed conf
sed -e "s/ORG/$ORG/g" \
        -e "s/AZ/$AZ/g" \
        -e "s/SU/$SU/g" \
        -e "s/WKS/$WKS/g" \
        -e "s/ENV/$ENV/g" \
         ./template/conf/sed/app.toml  > ./output/conf/sed/app.toml

sed -e "s/SOLACE_VPN/$SOLACE_VPN/g" \
        -e "s/SOLACE_USERNAME/$SOLACE_USERNAME/g" \
        -e "s/SOLACE_PASSWORD/$SOLACE_PASSWORD/g" \
        -e "s/SOLACE_HOST/$SOLACE_HOST/g" \
         ./template/conf/sed/sessions.toml  > ./output/conf/sed/sessions.toml